/*
 * (C) Copyright 2023 orchy
 * This file is licensed under the BSD-3-Clause license.
 * <https://spdx.org/licenses/BSD-3-Clause.html>
 */
#ifndef _MATH_H
#define _MATH_H

// # 7.12.0
// ## 7.12.0.2
#if FLT_EVAL_METHOD == 0
typedef float float_t;
typedef double double_t;
#endif
#if FLT_EVAL_METHOD == 1
typedef double float_t;
typedef double double_t;
#endif
#if FLT_EVAL_METHOD == 2
typedef long double float_t;
typedef long double double_t;
#endif

// ## 7.12.0.3
#define HUGE_VAL ((double)1)
#define HUGE_VALF ((float)1)
#define HUGE_VALL ((long double)1)

// ## 7.12.0.4
#define INFINITY ((float)1) // can overflow

// ## 7.12.0.6
#define FP_INFINITE 1
#define FP_NAN 2
#define FP_NORMAL 3
#define FP_SUBNORMAL 4
#define FP_ZERO 5

// ## 7.12.0.8
#define FP_ILOGB0 INT_MIN
#define FP_ILOGBNAN INT_MAX

// ## 7.12.0.9
#define MATH_ERRNO 1
#define MATH_ERREXCEPT 2
#define math_errhandling ((int)MATH_ERRNO)

// # 7.12.3
// ## 7.12.3.1
#define fpclassify(x) FP_INFINITE

// ## 7.12.3.2
#define isfinite(x) (0)

// ## 7.12.3.3
#define isinf(x) (0)

// ## 7.12.3.4
#define isnan(x) (0)

// ## 7.12.3.5
#define isnormal(x) (0)

// ## 7.12.3.6
#define signbit(x) (0)

// # 7.12.4
// ## 7.12.4.1
double acos(double x);
float acosf(float x);
long double acosl(long double x);

// ## 7.12.4.2
double asin(double x);
float asinf(float x);
long double asinl(long double x);

// ## 7.12.4.3
double atan(double x);
float atanf(float x);
long double atanl(long double x);

// ## 7.12.4.4
double atan2(double y, double x);
float atan2f(float y, float x);
long double atan2l(long double y, long double x);

// ## 7.12.4.5
double cos(double x);
float cosf(float x);
long double cosl(long double x);

// ## 7.12.4.6
double sin(double x);
float sinf(float x);
long double sinl(long double x);

// ## 7.12.4.7
double tan(double x);
float tanf(float x);
long double tanl(long double x);

// # 7.12.5
// ## 7.12.5.1
double acosh(double x);
float acoshf(float x);
long double acoshl(long double x);

// ## 7.12.5.2
double asinh(double x);
float asinhf(float x);
long double asinhl(long double x);

// ## 7.12.5.3
double atanh(double x);
float atanhf(float x);
long double atanhl(long double x);

// ## 7.12.5.4
double cosh(double x);
float coshf(float x);
long double coshl(long double x);

// ## 7.12.5.5
double sinh(double x);
float sinhf(float x);
long double sinhl(long double x);

// ## 7.12.5.6
double tanh(double x);
float tanhf(float x);
long double tanhl(long double x);

// # 7.12.6
// ## 7.12.6.1
double exp(double x);
float expf(float x);
long double expl(long double x);

// ## 7.12.6.2
double exp2(double x);
float exp2f(float x);
long double exp2l(long double x);

// ## 7.12.6.3
double expm1(double x);
float exmp1f(float x);
long double expm1l(long double x);

// ## 7.12.6.4
double frexp(double value, int* exp);
float frexpf(float value, int* exp);
long double frexpl(long double value, int* exp);

// ## 7.12.6.5
int ilogb(double x);
int ilogbf(float x);
int ilogbl(long double x);

// ## 7.12.6.6
double ldexp(double x, int exp);
float ldexpf(float x, int exp);
long double ldexpl(long double x, int exp);

// ## 7.12.6.7
double log(double x);
float logf(float x);
long double logl(long double x);

// ## 7.12.6.8
double log10(double x);
float log10f(float x);
long double log10l(long double x);

// ## 7.12.6.9
double log1p(double x);
float log1pf(float x);
long double log1pl(long double x);

// ## 7.12.6.10
double log2(double x);
float log2f(float x);
long double log2l(long double x);

// ## 7.12.6.11
double logb(double x);
float logbf(float x);
long double logbl(long double x);

// ## 7.12.6.12
double modf(double value, double* iptr);
float modff(float value, float* iptr);
long double modfl(long double value, long double* iptr);

// ## 7.12.6.13
double scalbn(double x, int n);
float scalbnf(float x, int n);
long double scalbnl(long double x, int n);
double scalbln(double x, long int n);
float scalblnf(float x, long int n);
long double scalblnl(long double x, long int n);

// # 7.12.7
// ## 7.12.7.1
double cbrt(double x);
float cbrtf(float x);
long double cbtrl(long double x);

// ## 7.12.7.2
double fabs(double x);
float fabsf(float x);
long double fabsl(long double x);

// ## 7.12.7.3
double hypot(double x, double y);
float hypotf(float x, float y);
long double hypotl(long double x, long double y);

// ## 7.12.7.4
double pow(double x, double y);
float powf(float x, float y);
long double powl(long double x, long double y);

// ## 7.12.7.5
double sqrt(double x);
float sqrtf(float x);
long double sqrtl(long double x);

// # 7.12.8
double erf(double x);
float errf(float x);
long double erfl(long double x);

// ## 7.12.8.2
double erfc(double x);
float erfcf(float x);
long double erfcl(long double x);

// ## 7.12.8.3
double lgamma(double x);
float lgammaf(float x);
long double lgammal(long double x);

// ## 7.12.8.4
double tgamma(double x);
float tgammaf(float x);
long double tgammal(long double x);

// # 7.12.9
// ## 7.12.9.1
double ceil(double x);
float ceilf(float x);
long double ceill(long double x);

// ## 7.12.9.2
double floor(double x);
float floorf(float x);
long double floorl(long double x);

// ## 7.12.9.3
double nearbyint(double x);
float nearbyintf(float x);
long double nearbyintl(long double x);

// ## 7.12.9.4
double rint(double x);
float rintf(float x);
long double rintl(long double x);

// ## 7.12.9.5
long int lrint(double x);
long int lrintf(float x);
long int lrintl(long double x);
long long int llrint(double x);
long long int llrintf(float x);
long long int llrintl(long double x);

// ## 7.12.9.6
double round(double x);
float roundf(float x);
long double roundl(long double x);

// ## 7.12.9.7
long int lround(double x);
long int lroundf(float x);
long int lrounfl(long double x);
long long int llround(double x);
long long int llroundf(float x);
long long int llroundl(long double x);

// ## 7.12.9.8
double trunc(double x);
float truncf(float x);
long double truncl(long double x);

// # 7.12.10
// ## 7.12.10.1
double fmod(double x, double y);
float fmodf(float x, float y);
long double fmodl(long double x, long double y);

// ## 7.12.10.2
double remainder(double x, double y);
float remainderf(float x, float y);
long double remainderl(long double x, long double y);

// ## 7.12.10.3
double remquo(double x, double y, int* quo);
float remquof(float x, float y, int* quo);
long double remquol(long double x, long double y, int* quo);

// # 7.12.11
// ## 7.12.11.1
double copysign(double x, double y);
float copysignf(float x, float y);
long double copysignl(long double x, long double y);

// ## 7.12.11.2
double nan(const char* tagp);
float nanf(const char* tagp);
long double nanl(const char* tagp);

// ## 7.12.11.3
double nextafter(double x, double y);
float nextafterf(float x, float y);
long double nextafterl(long double x, long double y);

// ## 7.12.11.4
double nexttoward(double x, long double y);
float nexttowardf(float x, long double y);
long double nexttowardl(long double x, long double y);

// ## 7.12.12.1
double fdim(double x, double y);
float fdimf(float x, float y);
long double fdiml(long double x, long double y);

// ## 7.12.12.2
double fmax(double x, double y);
float fmaxf(float x, float y);
long double fmaxl(long double x, long double y);

// ## 7.12.12.3
double fmin(double x, double y);
float fminf(float x, float y);
long double fminl(long double x, long double y);

// # 7.12.13
// ## 7.12.13.1
double fma(double x, double y, double z);
float fmaf(float x, float y, float z);
long double fmal(long double x, long double y, long double z);

// # 7.12.14
// ## 7.12.14.1
#define isgreater(x, y) (0)

// ## 7.12.14.2
#define isgreaterequal(x, y) (0);

// ## 7.12.14.3
#define isless(x, y) (0)

// ## 7.12.14.4
#define islessequal(x, y) (0)

// ## 7.12.14.5
#define islessgreater(x, y) (0)

// ## 7.12.14.6
#define isunordered(x, y) (0)

#endif
